<template>
  <view class="">
    <ve-form-item label="合同信息">
      <template v-if="contractItem.status == 'view'">
        <pre-file :id="contractItem.contractFileId" />
      </template>
      <template v-else>
        <upload-file
          v-model:fileId="contractItem.contractFileId"
          v-model:fileName="contractItem.contractFileName"
          :fileTypes="['doc', 'docx', 'pdf']"
          @change="uploadSuccess"
          :fileIndex="contractIndex"
        />
      </template>
    </ve-form-item>
    <!-- <ve-form-item
      :prop="`contractList.${contractIndex}.contractNo`"
      :required="contractItem.contractFileId ? true : false"
      label="合同编号"
      :borderBottom="false"
    >
      <template v-if="contractItem.contractFileId">{{ contractItem.contractNo }}</template>
      <text v-else>-</text>
    </ve-form-item> -->
  </view>
</template>
<script setup>
  import { getContractNoAPI } from '@/api/order/lOrder'
  import uploadFile from '@/components/upload-file'
  import preFile from '@/components/upload-file/pre-file'

  const props = defineProps({
    contractItem: {
      type: Object,
      default: () => {},
    },
    contractIndex: Number,
  })
  // 选择文件
  const uploadSuccess = () => {
    const param = {
      type: 1, // 1：下单 2:续租 3:换车
    }
    getContractNoAPI(param).then((res) => {
      const result = res.result
      props.contractItem.contractNo = result
    })
  }
</script>
<style lang="less" scoped></style>
